package com.java.thread;

import com.java.Company;

/**
 * @author
 * @date 2018/9/13 15:29
 */
public class Calculate implements Runnable {


    private  Company company;

    public Calculate(Company company) {
        this.company = company;
    }

    public Calculate() {
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    @Override
    public void run() {
        synchronized (company){
            System.out.println("threadId:" + Thread.currentThread().getId());
            System.out.println(company.getId());
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            company.setValue(company.getId());
        }
    }
}